﻿#ifndef TRAJECTORYPOINTS_H
#define TRAJECTORYPOINTS_H

#include <QtCore/QObject>
#include <QtCore/qglobal.h>
#include <QVariantList>
#include <QGeoCoordinate>

class MapModel;

class TrajectoryPoints : public QObject
{
    Q_OBJECT

public:
    TrajectoryPoints(MapModel* mapModel, QObject* parent = nullptr);

    Q_INVOKABLE QVariantList list(void) const { return _points; }

    void start  (void);
    void stop   (void);

public slots:
    void clear  (void);

signals:
    void homeCoordinateChanged(QGeoCoordinate coordinate);
    void pointAdded     (QGeoCoordinate coordinate);
    void updateLastPoint(QGeoCoordinate coordinate, double azimuth);
    void pointsCleared  (void);

private slots:
    void _onVehicleCoordinateChanged(QGeoCoordinate coordinate);

private:
    MapModel*       _mapModel;
    QVariantList    _points;
    QGeoCoordinate  _lastVehiclePoint;
    double          _lastAzimuth;

    static constexpr double _DistanceTolerance = 2.0;
    static constexpr double _AzimuthTolerance = 1.5;
};


#endif // TRAJECTORYPOINTS_H
